home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 July: Mac OS SDK / Dev.CD Jul 97 SDK1.toast / Development Kits (Disc 1) / QuickDraw GX / Programming Stuff / Sample Code / Printing Samples / Extensions… / Additions ƒ / DespoolPageMessage.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-06-14  |  3.9 KB  |  132 lines  |  [TEXT/MPS ]

  1. /* ------------------------------------------------------------------------------
  2.  
  3.     FILENAME
  4.         DespoolPageMessage.c
  5.  
  6.     DESCRIPTION
  7.         This file contains the message procedure that will be invoked when the Printing Manager
  8.         issues the DespoolPage message.  The routine which is called is DespoolPageMessageProc.
  9.         Depending upon the effects the user selected in the Addition's Print dialog panel, 
  10.         DespoolPageMessageProc will invoke routines in the Additions.c file to produce the
  11.         desired effects.
  12.  
  13.     COPYRIGHT
  14.         Copyright Apple Computer, Inc. 1991 - 1996
  15.         All rights reserved. 
  16.     
  17.     INTERFACE ROUTINES
  18.         DespoolPageMessageProc
  19.  
  20.     MODIFICATION HISTORY
  21.         05/15/91            ALA                Initial Implementation
  22.          6/14/96            cn                    Updated to support Universal Interfaces 2.1.
  23.  
  24.  
  25. ------------------------------------------------------------------------------- */
  26.  
  27. #include <Types.h>
  28. #include <Quickdraw.h>
  29. #include <Memory.h>
  30. #include <Resources.h>
  31. #include <Dialogs.h>
  32. #include <TextEdit.h>
  33. #include <OSUtils.h>
  34. #include <Packages.h>
  35. #include <ToolUtils.h>
  36. #include <Menus.h>
  37. #include <String.h>
  38. #include <Strings.h>
  39. #include <Printing.h>
  40.  
  41. #include <GXGraphics.h>
  42. #include <GraphicsLibraries.h>
  43. #include <FontLibrary.h>
  44.  
  45. #include <Collections.h>
  46. #include <GXMessages.h>
  47.  
  48. #include    <GXPrinting.h>
  49.  
  50. #include "Utilities.h"
  51. #include "Additions.h"
  52.  
  53.  
  54.  /*================================== MESSAGE INTERFACE ROUTINES ==================================*/
  55.  
  56.  
  57. /* ===== DespoolPageMessageProc =====
  58.  
  59.     DespoolPageMessageProc is the extension's routine which will be invoked when Printing issues a 
  60.     despoolPage message.  This routine will first make sure the page is despooled by calling
  61.     Forward_DespoolPage.  Once the page is despooled, it checks to see if a page border should
  62.     be added to the page. If so, the AddPageBorder routine is called.  It also checks to
  63.     see if we're to serialize the copies.  If so, a shape is created which will
  64.     be used to add the serial number to the page at render page time.
  65. */
  66. OSErr DespoolPageMessageProc(        //    (out)    Error code
  67.     gxSpoolFile    theSpoolFile,        //    (in)    Reference to the spool file being written to
  68.     long            pageNum,                //    (in)    Number of the page being despooled
  69.     gxFormat        theFormat,            //    (in)    Format reference for the page being spooled
  70.     gxShape        *thePage,            //    (out)    The page shape being despooled; we may add items to the page
  71.     Boolean        *formatChanged)    //    (out)    true => format changed since last despooled page; false otherwise
  72. {
  73.     
  74.     OSErr anErr;
  75.     
  76.     /* Make sure the page is despooled before we access it */
  77.     anErr = Forward_GXDespoolPage (theSpoolFile, pageNum, theFormat, thePage, formatChanged);
  78.     if (anErr == noErr)
  79.     {
  80.         gxJob                            documentJob;
  81.         Collection                    jobCollection;
  82.         AdditionsCollection        additionsConfig;
  83.         
  84.         /* Get a reference to the current job */
  85.         documentJob = GXGetJob();
  86.     
  87.         /* Get reference to the print Job's collection */
  88.         jobCollection = GXGetJobCollection(documentJob);
  89.         
  90.         /* Fetch the Additions's collection we created at Print dialog time */
  91.         anErr = GetCollectionItem (jobCollection,
  92.                                             kAdditionsCollectionType,
  93.                                             gxPrintingTagID,
  94.                                             nil,
  95.                                             &additionsConfig);
  96.         if (anErr == noErr)
  97.         {
  98.             /* If user selected the page border addition, add it now */
  99.             if (additionsConfig.addPageBorder)
  100.             {
  101.                 gxJobInfo        printerInfo;
  102.     
  103.                 /* Get the general printing info. collection item */
  104.                 anErr = GetCollectionItem (jobCollection,
  105.                                                     gxJobTag,
  106.                                                     gxPrintingTagID,
  107.                                                     nil,
  108.                                                     &printerInfo);
  109.                 if (anErr == noErr)
  110.                 {
  111.                     anErr = AddPageBorder(*thePage, theFormat, printerInfo.documentName);
  112.                 }
  113.             }
  114.             
  115.             if (anErr == noErr)
  116.             {
  117.                 /* Indicate that we don't have a serial number shape yet. The shape will get */
  118.                 /* created at RenderPage message time. */
  119.                 if (additionsConfig.serializeCopies)
  120.                 {
  121.                     gSerialShape = nil;
  122.                 }
  123.             }
  124.         }
  125.         else    // T => no config; don't do anything
  126.             anErr = noErr;
  127.     }
  128.  
  129.     return(anErr);
  130. }
  131. /* DespoolPageMessageProc */
  132.